<?php
/**
 * Here are some example uses for the client!
 */

//Include the client
include_once('pownce.class.php');

//Open the client up
//NOTE: You may specify a user to open it for, but it is not required.  However if you do not some functions may not work, but most should.
$pownceAPIobj = new PownceXML('leahculver');

echo "The client has been opened for: " . $pownceAPIobj->get_username() . "<br>\n";

echo "<h1>Stat utilities</h1>\n";

//How many links has the user sent?
echo "\n<br>Link count:\n<br>";
echo $pownceAPIobj->link_count();

//How many events has another user sent?
echo "\n<br>Event count for another user:\n<br>";
echo $pownceAPIobj->event_count('Onetrap');

//How much for friends does Daniel have than I :)
echo "\n<br>Friend count:\n<br>";
echo $pownceAPIobj->friend_count();

//I only have...
echo "\n<br>Friend count of another user:\n<br>";
echo $pownceAPIobj->friend_count('Onetrap');

echo "<h1>Relation checks!</h1>\n";

//However Daniel and I are friends!  Thanks for lunch Daniel!
echo "\n<br>Are the user and another user friends?\n<br>";
if($pownceAPIobj->is_friend('Onetrap')) {
    echo "yes!";
}
else {
    echo "no! :(";
}

//Are 2 people friends?
echo "\n<br>Are the user and another user friends?\n<br>";
if($pownceAPIobj->is_friend('kevin', 'leahculver')) {
    echo "yes!";
}
else {
    echo "no! :(";
}

echo "<h1>Public Notes</h1>";

//Get most recent public event
echo "\n<br>Most recent public event body blurb:\n<br>";
$event = $pownceAPIobj->get_public_events(1);
echo $event[1]['body'];

echo "<h1>Person's Notes</h1>";
//Lets get 6 of that persons public notes

$persons_notes = $pownceAPIobj->get_persons_public_notes_from(null, null, 6);

//For each of the notes, do some stuff to display
foreach ($persons_notes as $note) {
    echo "Note by:\n<br>"
    . $note['sender']['user']['username']
    . "<img src=\""
    . $note['sender']['user']['profile_photo_urls']['medium_photo_url']
    . "\">"
    . "\n<br>The note says:\n<br>"
    . $note['body']
    . "\n<br>The note was sent:\n<br>"
    . $note['display_since']
    . "\n<br>So on and so forth...<hr>";
}
?>